const UsersModel  = require("../../db/user");

class UsersSql {
  signup({ username, password }) {
    const user = new UsersModel({
      username,
      password,
    });
    return user.save();
  }
  findUser(username) {
    return UsersModel.findOne({ username });
  }
  findAllUsers() {
    return UsersModel.find();
  }
  deleteUser(id) {
    return UsersModel.findByIdAndDelete(id);
  }
  editUser(id, username, password) {
    return UsersModel.findOneAndUpdate({ _id: id }, { username, password })
  }
}
module.exports = UsersSql